/*
 * Shader.h
 *
 *  Created on: May 28, 2011
 *      Author: Ernest Mashele <mashern@gmail.com>
 */

#ifndef SHADER_H_
#define SHADER_H_

#include "Helper.h"

class Material;

class Shader
{
public:
	Shader();
	virtual ~Shader();

	bool Initialize(ID3D10Device* pDevice, HWND hWnd);
	void Render(ID3D10Device*, int, D3DXMATRIX, D3DXMATRIX, D3DXMATRIX,
			ID3D10ShaderResourceView*, D3DXVECTOR3, D3DXVECTOR3, D3DXVECTOR4,
			D3DXVECTOR4, D3DXVECTOR4, float);
	void SetShaderVariables(D3DXMATRIX World, D3DXMATRIX View,
			D3DXMATRIX Projection, D3DXVECTOR3 CameraPosition, Material *p, ID3D10ShaderResourceView* pTexture);

private:
	bool CreateInputLayout(ID3D10Device* pDevice);
	void SetShaderParameters(D3DXMATRIX, D3DXMATRIX, D3DXMATRIX,
			ID3D10ShaderResourceView*, D3DXVECTOR3, D3DXVECTOR3, D3DXVECTOR4,
			D3DXVECTOR4, D3DXVECTOR4, float);
	void RenderShader(ID3D10Device*, int);
	void ObtainShaderVariables();

private:
	ID3D10Effect* pEffect;
	ID3D10EffectTechnique* pEffectTechnique;
	ID3D10InputLayout* pVertexLayout;

	ID3D10EffectMatrixVariable* WorldVariable;
	ID3D10EffectMatrixVariable* ViewVariable;
	ID3D10EffectMatrixVariable* ProjectionVariable;
	ID3D10EffectShaderResourceVariable* pTextureRV;

	ID3D10EffectVectorVariable* pCameraPositionVariable;
	ID3D10EffectVectorVariable* pAmbientVariable;
	ID3D10EffectVectorVariable* pDiffuseVariable;
	ID3D10EffectVectorVariable* pSpecularVariable;
	ID3D10EffectScalarVariable* pSpecularPowerVariable;
};

#endif /* SHADER_H_ */
